package cn.wolfcode.rbac.web.controller;

import cn.wolfcode.rbac.domain.Permission;
import cn.wolfcode.rbac.query.QueryObject;
import cn.wolfcode.rbac.service.IPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by Administrator on 2020/6/10 0010.
 */
@Controller
public class PermissionController {
    @Autowired
    private IPermissionService permissionService;

    /**
     * 接收浏览器发送过来的请求
     * @RequestMapping("资源的路径")
     * @return 视图的路径
     */
    @RequestMapping("/permission/list")
    public String list(Model model, QueryObject queryObject){
//        <property name="prefix" value="/WEB-INF/views/"/>
//		<property name="suffix" value=".jsp"/>
        model.addAttribute("result",permissionService.query(queryObject));
        return "permission/list";
    }

    @RequestMapping("/permission/delete")
    public String delete(Long id){
        permissionService.delete(id);
        return  "redirect:/permission/list.do";
    }

    @RequestMapping("/permission/reload")
    public String reload(){
        permissionService.reload();
        return "redirect:/permission/list.do";
    }


}
